package com.hilihili.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hilihili.domain.entity.Emojilist;
import com.hilihili.service.IEmojilistService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * emoji表情Controller
 *
 * @author xhc
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/hilihili/emojilist")
public class EmojilistController extends BaseController
{
    @Autowired
    private IEmojilistService emojilistService;

    /**
     * 查询emoji表情列表
     */
    @GetMapping("/list")
    public AjaxResult list(Emojilist emojilist)
    {
        List<Emojilist> list = emojilistService.selectEmojilistList(emojilist);
        return AjaxResult.success(list);
    }

    /**
     * 导出emoji表情列表
     */
    @PreAuthorize("@ss.hasPermi('hilihili:emojilist:export')")
    @Log(title = "emoji表情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Emojilist emojilist)
    {
        List<Emojilist> list = emojilistService.selectEmojilistList(emojilist);
        ExcelUtil<Emojilist> util = new ExcelUtil<Emojilist>(Emojilist.class);
        util.exportExcel(response, list, "emoji表情数据");
    }

    /**
     * 获取emoji表情详细信息
     */
    @PreAuthorize("@ss.hasPermi('hilihili:emojilist:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(emojilistService.selectEmojilistById(id));
    }

    /**
     * 新增emoji表情
     */
    @PreAuthorize("@ss.hasPermi('hilihili:emojilist:add')")
    @Log(title = "emoji表情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Emojilist emojilist)
    {
        return toAjax(emojilistService.insertEmojilist(emojilist));
    }

    /**
     * 修改emoji表情
     */
    @PreAuthorize("@ss.hasPermi('hilihili:emojilist:edit')")
    @Log(title = "emoji表情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Emojilist emojilist)
    {
        return toAjax(emojilistService.updateEmojilist(emojilist));
    }

    /**
     * 删除emoji表情
     */
    @PreAuthorize("@ss.hasPermi('hilihili:emojilist:remove')")
    @Log(title = "emoji表情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(emojilistService.deleteEmojilistByIds(ids));
    }
}
